<template>
  <div class="vue-box sbot-fluid sbot">
    <div class="c-panel">
      <el-form :inline="true">
        <sa-item v-model="m.name" type="text" name="租户名称" br />
        <sa-item v-model="m.code" type="text" name="租户编码" br />
        <sa-item v-model="m.phone" type="text" name="电话号码" br />
        <sa-item v-model="m.status" type="enum" jtype="3" :jv="dims.YES_OR_NO" name="启用状态" br />
        <sa-item v-model="m.note" type="text" name="描述" br />
        <sa-item v-model="m.sort" type="num" name="序号" br />
        <sa-item name="" class="s-ok" br>
          <el-button type="primary" icon="el-icon-plus" @click="ok()">保存</el-button>
        </sa-item>
      </el-form>
    </div>
  </div>
</template>

<script>
export default {
  name: 'rent-add',
  props: { param: Object },
  data() {
    return {
      // 超级对象
      m: this.createModel(),
      dims: this.param.dims
    }
  },
  created: function () {
  },
  methods: {
    // 创建一个 默认Model
    createModel() {
      return {
        name: null,
        code: null,
        account: null,
        phone: null,
        note: null,
        status: null,
        sort: null,
        sids: []
      }
    },
    // 提交数据
    ok: function () {
      // 验证 获取 m对象
      let m = this.m;
      sa.checkNull(m.name, '请输入租户名字');
      sa.checkNull(m.code, '请输入租户编码');
      sa.checkNull(m.phone, '请输入管理员电话号码');

      // 开始增加
      sa.ajax('/rent/add', this.m, function (res) {
        sa.alert('租户添加成功', function () {
          this.m = this.createModel();
          sa.closeModel();
          sa.currView().f5();
        }.bind(this));
      }.bind(this));
    },
  }
}
</script>

<style scoped></style>
